home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Directorty Opus 5 - Magellan 2
/
Opus 5 - Magellan 2.iso
/
Extras
/
dirmaster
/
dirmaster.dopus5
next >
Wrap
Text File
|
1997-02-27
|
5KB
|
141 lines
/*****************************************************************\
* *
* DIRTODEST and PARENTTODEST commands for Directory Opus 5 *
* *
* Written by Timo Kaikumaa (timok@cc.tut.fi) *
* *
* ARexx script for Directory Opus 5.5 giving you two new *
* directory & lister commands. To make them work, place this *
* script into "dopus5:modules" directory. *
* *
* This script was written because I wasn't happy with _any_ *
* command or script of this kind there was already available. *
* (And there sure was loads of them.) *
* *
* Using these commands results in another lister with the *
* same path (DirToDest) or the parent path of your current *
* directory (ParentToDest) in it. However, the algorithm to *
* determine the new lister is more complex than usually. *
* When called without legal arguments, the state of the *
* destination listers is first checked. If there is only one *
* of them (and it's not the lister where this script was called *
* from) it is the one to be used, then. However, if the command *
* was used in the actual destination lister the same applies to *
* the source listers as well. If these criterions are of no use, *
* a new check is performed. This time a pathless lister is being *
* looked for. Usually this means a lister showing the list of *
* devices or current caches. If there are many of them, only the *
* first one is used. In case the search appears still *
* unsuccessful, a new lister is finally opened. *
* *
* If there are selected directories in a lister where DirToDest *
* is called from, the first of these is being used instead of *
* current directory. This action also deselects the first *
* directory entry. *
* *
* Both commands can only be used within a lister context. *
* *
* Parameters: NEW/S to always open a new lister. *
* *
* Bugs: perhaps customized too much to suit for anyone's taste. *
* *
* Hint: the first lines of lister menu might be a good place *
* for these commands. *
* *
\*****************************************************************/
/* $VER: dirmaster.dopus5 1.3 (27.2.97)
*/
parse arg portname function source dest arguments
address value portname
options results
/* Initialization */
if function = 'init' then do
dopus command "DirToDest" program "dirmaster" desc "'Clones current directory'" template "'NEW/S'" source
dopus command "ParentToDest" program "dirmaster" desc "'Clones parent directory'" template "'NEW/S'" source
exit
end
/* DirToDest */
if function = 'DirToDest' then do
if source = 0 then do
dopus request '"DirToDest cannot be used outside lister!"'
exit
end
lister query source path
mypath = RESULT
lister query source seldirs stem dirs
if dirs.count ~= 0 then do
mypath = mypath || dirs.0 || '/'
lister select source dirs.0 off
lister refresh source
end
call doit
end
/* ParentToDest */
if function = 'ParentToDest' then do
if source = 0 then do
dopus request '"ParentToDest cannot be used outside lister!"'
exit
end
lister query source path
mypath = left(RESULT,max(lastpos(':',RESULT),(lastpos('/',strip(RESULT,'T','/')))))
call doit
end
/* Common exit point */
exit
/* Let's do it */
doit:
if mypath = "" then return
if arguments = "NEW" then do
lister new mypath
return
end
lister query "dest" stem dests
if dests.count = 1 then do
if dests.0 ~= source then do
lister read dests.0 mypath
return
end
else do
lister query "source" stem dests
if dests.count = 1 then do
lister read dests.0 mypath
return
end
end
end
lister query all stem dests
do i=0 for dests.count
if (source ~= dests.i) then do
lister query dests.i path
if RESULT = "" then do
lister read dests.i mypath
return
end
end
end
lister new mypath
return